<template>
	<view class="center_bg">
		<!-- 个人 -->
		<view class="cneter_top" @click="GoUserMass()" v-if="logintype==2">
			<view class="center_mass">
				<view class="pic">
					<image mode="widthFix" src="../../static/images/c_i1.png" ></image>
				</view>
				<view class="text">
					<view class="h4">{{info.nickname}}
						<!-- <view class="code" @click.stop="LookCode(1,'/pages/center/integralcode')">
							<view class="aa">
								<image mode="widthFix" src="../../static/images/c_i2.png"></image><text>积分核销码</text>
							</view>

						</view> -->
					</view>
					<view class="phone">
						<text v-if="info.phone">{{info.phone.substring(0,3)}}****{{info.phone.substring(7,11)}}</text>
					</view>
				</view>
			</view>
		</view>

		<!-- 商户 -->
		<view class="cneter_top" @click="GoShopMass()" v-if="logintype==1">
			<view class="center_mass">
				<view class="pic">
					<image mode="widthFix" src="../../static/images/c_i1.png"></image>
				</view>
				<view class="text">
					<view class="h4">{{info.nickname}}
						<view class="code" @click.stop="LookCode(2,'/pages/shop/code')">
							<view>
								<image mode="widthFix" src="../../static/images/c_i2.png"></image><text>商户会员注册码</text>
							</view>
						</view>
					</view>
					<view class="shanghu">
						<view>
							<image mode="widthFix" src="../../static/images/c_i6.png"></image><text>柏杨联盟商户</text>
						</view>

					</view>
				</view>
			</view>
		</view>


		<!-- 我的钱包 -->
		<view class="my_order" style="margin-top: 42rpx;">
			<view class="con">
				<view class="more_title">
					<text class="h4">我的钱包</text>
					<navigator class="two" url="/pages/center/money" hover-class="none">
						<view class="span"><text>查看明细</text>
							<image mode="widthFix" src="../../static/images/app_i3.png"></image>
						</view>
					</navigator>
				</view>
				<view class="order_icon">
					<view class="left">
						<view class="span">总资产（元）</view>
						<view class="b">{{info.balance}}</view>
					</view>
					<navigator url="/pages/center/out" hover-class="none">
						<view class="btn">去提现</view>
					</navigator>
				</view>
			</view>
		</view>
		<!-- 我的钱包 end -->

		<!-- 我的积分 -->
		<view class="my_order" style="margin-top: 20rpx;">
			<view class="con">
				<view class="more_title">
					<text class="h4">我的积分</text>
					<navigator class="two" url="/pages/center/integral" hover-class="none">
						<view class="span"><text>查看明细</text>
							<image mode="widthFix" src="../../static/images/app_i3.png"></image>
						</view>
					</navigator>
				</view>
				<view class="order_icon">
					<view class="left">
						<view class="span">总积分</view>
						<view class="b">{{info.integral}}</view>
					</view>
					
					<navigator url="/pages/center/integral" hover-class="none">
						<view class="btn">查看积分</view>
					</navigator>
					
					<!-- <view class="btn" @click.stop="LookCode(1,'/pages/center/integralcode')">
						<image src="../../static/images/c_i7.png" mode="widthFix"></image>
						<text>积分核销码</text>
					</view> -->
				</view>
				<navigator url="/pages/shop/scan" hover-class="none" v-if="logintype==1">
					<view class="center_btn">
						<text>积分核销</text>
					</view>
				</navigator>
				<view class="h30" v-if="logintype==1"></view>
			</view>
		</view>
		<!-- 我的积分 end -->

		<!-- 我的会员 只有商户有 -->
		<!-- <view class="my_order" style="margin-top: 20rpx;" v-if="logintype==1">
			<view class="con">
				<view class="more_title">
					<text class="h4">我的会员</text>
					<navigator class="two" url="/pages/shop/member" hover-class="none">
						<view class="span"><text>我的收益</text>
							<image mode="widthFix" src="../../static/images/app_i3.png"></image>
						</view>
					</navigator>
				</view>
				<view class="order_icon" style="padding-left: 100rpx;padding-right: 100rpx;">
					<navigator :url="'/pages/shop/member?id=' + info.merchant.merchantno + '&name=' + info.merchant.name" hover-class="none">
						<view class="left2">
							<view class="span">{{info.totalFee}}</view>
							<view class="b">累计收益（万元）</view>
						</view>
					</navigator>
					<navigator :url="'/pages/shop/list?id=' + info.merchant.merchantno + '&name=' + info.merchant.name" hover-class="none">
						<view class="left2">
							<view class="span" >{{info.memberCount}}</view>
							<view class="b">累计会员</view>
						</view>
					</navigator>
				</view>
				
				
				<view class="h30"></view>
			</view>
		</view> -->
		<!-- 我的会员 end -->

		<!-- 菜单 -->
		
		<view class="center_menu" v-if="logintype==1">
			<navigator :url="'/pages/shop/list?id=' + info.merchant.merchantno + '&name=' + info.merchant.name" hover-class="none">
				<view class="item">
					<view class="icon">
						<image src="../../static/images/i15.png" mode="widthFix"></image>
					</view>
					<text>我的会员</text>
				</view>
			</navigator>
			<navigator :url="'/pages/shop/member?id=' + info.merchant.merchantno + '&name=' + info.merchant.name" hover-class="none">
				<view class="item">
					<view class="icon">
						<image src="../../static/images/i16.png" mode="widthFix"></image>
					</view>
					<text>会员管理收益</text>
				</view>
			</navigator>
			<navigator :url="'/pages/shop/list2?id=' + info.merchant.merchantno + '&name=' + info.merchant.name" hover-class="none">
				<view class="item bb_none">
					<view class="icon">
						<image src="../../static/images/i17.png" mode="widthFix"></image>
					</view>
					<text>商户自存收益</text>
				</view>
			</navigator>
		</view>
		
		<view class="center_menu">
			<navigator url="/pages/center/usermass" hover-class="none" v-if="logintype==2">
				<view class="item">
					<view class="icon">
						<image src="../../static/images/c_i4.png" mode="widthFix"></image>
					</view>
					<text>基本信息</text>
				</view>
			</navigator>
			<navigator url="/pages/center/shopmass" hover-class="none" v-if="logintype==1">
				<view class="item">
					<view class="icon">
						<image src="../../static/images/c_i4.png" mode="widthFix"></image>
					</view>
					<text>基本信息</text>
				</view>
			</navigator>
			<navigator url="/pages/center/set" hover-class="none">
				<view class="item ">
					<view class="icon">
						<image src="../../static/images/c_i5.png" mode="widthFix"></image>
					</view>
					<text>账户安全</text>
				</view>
			</navigator>
			<navigator url="/pages/center/message" hover-class="none">
				<view class="item bb_none">
					<view class="icon">
						<image src="../../static/images/i13.png" mode="widthFix"></image>
					</view>
					<text>联盟管家留言板</text>
				</view>
			</navigator>
		</view>
		<!-- 菜单 end -->
		<view class="h"></view>
	</view>
</template>

<script>
	import JWeixin from "weixin-js-sdk";
	export default {
		data() {
			return {
				logintype: 0,
				info: [],
				huiyuaninfo:[],
			}
		},
		onLoad() {
			let that = this;

			JWeixin.config({
				debug: false, // 开启调试模式
				appId: 'your-app-id', // 微信公众号的appId
				timestamp: 'your-timestamp', // 时间戳
				nonceStr: 'your-nonce-str', // 随机字符串
				signature: 'your-signature', // 签名
				jsApiList: ['chooseImage', 'uploadImage'] // 需要使用的JSSDK接口列表
			});

			if (that.common.GetStorage('byh5token')) {
				that.logintype = that.common.GetStorage('byh5type');
				
			} else {
				uni.reLaunch({
					url: '/pages/login/login',
				})
			}
		},
		
		onShow() {
			this.GetUserMass();
		},
		
		methods: {
			GetUserMass: function() {
				let that = this;
				uni.showLoading({
					title: '加载中...',
					mask: true
				});
				that.common.http('GET', 'user', '', function(res) {
					uni.hideLoading();
					console.log(res.data)
					that.info = res.data;
					
					// if(that.logintype==1){
					// 	that.GetList();
					// }					
				});
			},
			
			
			GetList: function() {
				let that = this;
				uni.showLoading({
					title: '加载中...',
					mask: true
				});
				that.common.http('GET', 'user/member', '', function(res) {
					uni.hideLoading();
					console.log(res.data)
					that.huiyuaninfo = res.data;
				});
			},

			GoUserMass: function() {
				uni.navigateTo({
					url: '/pages/center/usermass'
				})
			},
			GoShopMass: function() {
				uni.navigateTo({
					url: '/pages/center/shopmass'
				})
			},
			LookCode: function(num, url) {
				let that = this;
				if (num == 1 && that.info.integral == 0) {
					uni.showToast({
						icon: 'none',
						title: '积分不足',
						duration: 2000
					});
				} else {
					uni.navigateTo({
						url: url
					})
				}
			}
		}
	}
</script>

<style scoped>
	.center_bg {
		background-image: linear-gradient(to bottom, #daf3fd, #f7f7f7, #f7f7f7);
		padding: 0 24rpx;
	}
</style>